using Godot;
using System;

public partial class Main : Node
{
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{

		GameUtil.SetGameRoot(this);
		//GameUtil.SetScreenShotRoot(GetNode("sceneNode"));

		ViewConfig.init();
		ConfigManager.getInstance().init();
		//默认初始化的时候加载登陆场景
		var loginScene = ((PackedScene)GD.Load("res://scene/tileMapTest001.tscn")).Instantiate<SceneBase>();
		var sceneNode = GetNode("sceneNode/gameSceneNode");


		SceneUtil.sceneRootNode = sceneNode;

		SceneUtil.currentScene = loginScene;




		ViewManager.getInstance().viewRootNode = GetNode("viewNode");
		sceneNode.AddChild(loginScene);
		loginScene.EnterScene();

		this.onListenner();

		//SaveAndLoadManager.getInstance().Save();


	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
	}

	private void onListenner()
	{
		EventManager.getInstance().addListener(EventType.EVENT_CHANGE_SCENE, onChangeScene);

	}

	private void onChangeScene(object sender, EventParams e)
	{
		SceneManager.getInstance().enterScene((SceneId)e.paramDict["sceneId"]);
	}


}
